<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of FoMailConfirmation
 *
 * @author mssae-9
 */
class FoPaiementCarteBancaireCtrl extends jController {
    /**
    * Paiement carte bancaire sur FO
    */
    function index() {
        $rep = $this->getResponse('htmlFo');

        jClasses::inc('annonce~annoncePaiementSrv');
        jClasses::inc('formule~formuleSrv');

        $idOccasion         = $this->intParam('idOccasion') ;
        $formuleId          = $this->intParam('choix-form') ;
        $choixSelected      = $this->param('choix') ;

        $formuleSelected = common::chargeParId($formuleId, 'ao_formule');

        //calcul et mise à jour prix de l'annonce
        if ($choixSelected){
            $tabPrix = formuleSrv::getPrixOptionChoisie($choixSelected);
            $prixAnnonceChoix = $tabPrix[0]->prix_option;
        }

        $prixAnnonce = $formuleSelected->prix + $tabPrix[0]->prix_option;


        $rep->menusActifs = frontHtmlResponse::MENU_ANNONCE_GESTION ;
        $rep->breadCrumb  = array(frontHtmlResponse::MENU_ACCUEIL, frontHtmlResponse::MENU_ANNONCE_GESTION) ;

        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/popup.js');
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/front/js/pub.js');

        $nb_min = 1; 
        $nb_max = 10000;
        $nombre_cmd = rand($nb_min,$nb_max);

        $tarif   = $prixAnnonce;
        $montant = $tarif*100;
        $vendeur   = annoncePaiementSrv::getVendeur($idOccasion);

        $pathregret = 'http://' . $_SERVER['SERVER_NAME'] . jUrl::get('annonce~FoAnnoncePaiement:regret');
        $pathmerci = 'http://' . $_SERVER['SERVER_NAME'] .  jUrl::get("annonce~FoAnnonceGestion:saveFormuleOptionsEdited", array('idOcc'=>$idOccasion, 'cf'=>$formuleId,'choix'=>$choixSelected));


        $rep->bodyTpl = 'annonce~FoPaiementCarteBancaire';
        $rep->body->assign('montant',round($montant));
        $rep->body->assign('tarif',$tarif);
        $rep->body->assign('nombre_cmd',$nombre_cmd);
        $rep->body->assign('vendeur',$vendeur);
        $rep->body->assign('pathregret',$pathregret);
        $rep->body->assign('pathmerci',$pathmerci);

        return $rep;
    }


}

?>
